export function topTips(that, content, delay, type){
  var alert = {
    content: content,
    type: type,
    delay: delay,
    show: true
  }
  that.setData({
    alert: alert
  })
  if(delay != undefined){
    setTimeout(function () {
      alert.show = false
      that.setData({
        alert:alert
      })
    }, delay)
  }
}

export function tipsInfo(that, content, delay){
  topTips(that, content, delay, "info")
}
export function tipsSuccess(that, content, delay){
  topTips(that, content, delay, "success")
}
export function tipsError(that, content, delay){
  topTips(that, content, delay, "error")
}
export function hideTips(that){
  var alert = {show: false}
  that.setData({
    alert:alert
  })
}

module.exports = {
  tipsError,
  tipsSuccess,
  tipsInfo,
  hideTips
}